<template>
	<view class=""> 
		
	</view>
</template>

<script setup>
	
	import { computed, reactive,ref } from 'vue';
	  import sheep from '@/sheep';
	  import { showShareModal, showAuthModal } from '@/sheep/hooks/useModal';
		import { onLoad } from '@dcloudio/uni-app';
		
		const vips=[
			'/storage/myicon/20250324/0da6ad442becc6142059d0677b4b234d.png',//未开通
			'/storage/myicon/20250324/48e4b46db3d5fcf2a696050223a59298.png',//黄金
			'/storage/myicon/20250324/4c814b6c353eaa2daa54e236b8a19c0d.png',//白银
		]
		
		// const giveaway=[
		// 	'/storage/myicon/20250324/22514d82b240593051f59f66a9a48370.png',//BD   maker
		// 	'/storage/myicon/20250324/ef0036f44b822375f6c535157e6f92c5.png',//BDM  leader
		// 	'/storage/myicon/20250324/94d8c29e55576422e5231193e8225c5e.png',//服务中心  short_partner
		// 	'/storage/myicon/20250324/9e1848cbfc03f8cdf38456e698dea687.png',//区县  high_partner
		// 	'/storage/myicon/20250324/39e5b0a6bcc9fb0c726702d663f50753.png',//地市  founder
		// ]
		
		const giveaway={
			'maker':'/storage/myicon/20250324/22514d82b240593051f59f66a9a48370.png',//BD   maker
			'leader':'/storage/myicon/20250324/ef0036f44b822375f6c535157e6f92c5.png',//BDM  leader
			'short_partner':'/storage/myicon/20250324/94d8c29e55576422e5231193e8225c5e.png',//服务中心  short_partner
			'high_partner':'/storage/myicon/20250324/9e1848cbfc03f8cdf38456e698dea687.png',//区县  high_partner
			'founder':'/storage/myicon/20250324/39e5b0a6bcc9fb0c726702d663f50753.png',//地市  founder
		}
		
	  const isAuditMode = computed(() => sheep.$store('app').isAuditMode);
	  
	 
	  // 用户信息
	  const userInfo = computed(() => sheep.$store('user').userInfo);
	  // 是否登录
	  const isLogin = computed(() => sheep.$store('user').isLogin);
	  
	  const city_name =ref(null)
	  // 接收参数
	  const props = defineProps({
	    background: {
	      type: String,
	      default: '',
	    },
	    // 头像
	    avatar: {
	      type: String,
	      default: '',
	    },
	    nickname: {
	      type: String,
	      default: '请先登录',
	    },
	    vip: {
	      type: [String, Number],
	      default: '1',
	    },
	    collectNum: {
	      type: [String, Number],
	      default: '1',
	    },
	    likeNum: {
	      type: [String, Number],
	      default: '1',
	    },
	  });
	const DEFAULT_LOCATION = {
	  latitude: 30.308041, // 默认坐标
	  longitude: 120.372893,
	  city_name: "杭州市",
	};
	
	  function onBind() {
	    showAuthModal('changeMobile');
	  }
	  const getLocation = () => {
	   city_name.value='定位中'
	    uni.getLocation({
	      type: "wgs84",
	      success(res) {
	        const { latitude, longitude } = res;
	        getCityName(latitude, longitude);
	      },
	      fail(err) {
	        console.error("定位失败:", err);
	        // 定位失败时使用默认坐标
	        getCityName(DEFAULT_LOCATION.latitude, DEFAULT_LOCATION.longitude);
	        uni.showToast({
	          title: "定位失败",
	          icon: "none",
	          duration: 2000,
	        });
	      },
	    });
	  };
	  const getCityName = (latitude, longitude) => {
	    sheep.$api.data
	      .getcity({
	        latitude: latitude,
	        longitude: longitude,
	      })
	      .then((res) => {
	        if (res.error === 0) {
				city_name.value=res.data.name
	        }
	      });
	  };
	  const sign = async () => {
		  if(!userInfo?.is_signin){
			if (isLogin.value) {
				// const {error,data} = await sheep.$api.point.signUp()
				// userInfo.value.is_signin = true
			} else {
				showAuthModal()
			}
		  }
	  }
	  function init(){
		  // if (uni.getStorageSync('location')) {
		  // 		  if (JSON.parse(uni.getStorageSync('location'))?.city_name) {
		  // 		  		city_name.value=  JSON.parse(uni.getStorageSync('location'))?.city_name
		  // 				return
		  // 		  }
				//   return
		  // }
		  // getLocation()
		  
	  }
	  
	  onLoad(()=>{
		  init()
		  
	  })
</script>

<style>
</style>